package com.godox.beauty

import android.os.Bundle
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.godox.beauty.databinding.ActivityMainBinding
import com.godox.beauty.vm.MainViewModel
import com.godox.common.base.activity.BaseVmVbActivity

/**
 * 主页
 */
class MainActivity : BaseVmVbActivity<MainViewModel, ActivityMainBinding>() {

    //官方的全面屏沉浸配置方式，可要可不要，需要的话尽量都适配起来
//    override fun onCreate(savedInstanceState: Bundle?) {
//        super.onCreate(savedInstanceState)
//        enableEdgeToEdge()
//        setContentView(R.layout.activity_main)
//        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
//            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
//            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
//            insets
//        }
//    }

    override fun initView(savedInstanceState: Bundle?) {
        mViewBind.main.setOnClickListener {
            mViewModel.getMine()
        }
    }

    override fun showLoading(message: String) {
        TODO("Not yet implemented")
    }

    override fun dismissLoading() {
        TODO("Not yet implemented")
    }

    override fun createObserver() {
        mViewModel.demoLiveData.observe(this) {
            //TODO
        }
        mViewModel.mineLiveData.observe(this) {
            Toast.makeText(this@MainActivity, "${it.username}", Toast.LENGTH_SHORT).show()
        }

        mViewModel.errorLiveData.observe(this){
            Toast.makeText(this@MainActivity, "${it.message}", Toast.LENGTH_SHORT).show()
        }
    }
}